package acwing;

public class HaNoi2 {
    public static void main(String[] args){
        int n=2;
        Hanoi(n,'A','B','C'); //Hanoi(int n)
    }
    public static void Hanoi(int n,char A,char B,char C){
        if(n<=0){
            throw new IllegalArgumentException("n必须大于等于1");
        }
        if(n==1){
            System.out.println(A+"->"+B);
        }
        else{
            Hanoi(n-1,A,C,B);
            System.out.println(A+"->"+B);
            Hanoi(n-1,C,B,A);
        }
    }
}
